package com.yjc.springcloud.alibaba.controller;

import com.yjc.springcloud.alibaba.domain.CommonResult;
import com.yjc.springcloud.alibaba.service.StorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author shkstart
 * @create 2022-08-17 23:02
 */
@RestController
@Slf4j
public class StorageController {

    @Autowired
    StorageService storageService;

    @GetMapping("/storage/decrease")
    public CommonResult decreaseStorage(@RequestParam("productId") Long productId, @RequestParam("count") Integer count) {
        storageService.decreaseStorage(productId, count);
        return new CommonResult(200, "库存扣除成功~~~");
    }
}
